<template>
  <div id="mainbody">
    <router-view></router-view>
    <remind-bar :text="barText" v-if="barText"></remind-bar>
    <Footer></Footer>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';

import network from '@/libs/network';
import utils from '@/libs/utils';
import Footer from "./footer";
import remindBar from "@/components/modules/remindBar";
export default {
  name: "mainbody",
  data() {
    return {
      barText: ""
    };
  },
  mounted() {
    network(this.$el);
    // this.$el.removeEventListener('networkStatus', this.networkChange, false);
    // debugger;
    this.$el.addEventListener('networkStatus', this.networkChange, false);
  },
  components: {
    Footer,
    remindBar
  },
  computed: {
    ...mapGetters([
      'getNetworkStatus'
    ])
  },
  methods: {
    networkStatus(){
      let status = this.getNetworkStatus;
      // console.log(status);
      if(utils.getNetworkType(status) === 'none'){
        this.barText = '请连接网络';
      }else{
        this.barText = '';
      }
    },
    networkChange(e){
      this.$store.commit('setNetworkStatus', e.data);
      this.networkStatus();
    }
  }
};
</script>

<style scoped>
</style>
